﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="WebSOAPUI.Test" ValidateRequest="false" %>

<!DOCTYPE html >

<html xmlns="http://www.w3.org/1999/xhtml" ng-app="appModule">
<head runat="server">
    <title>测试</title>
    <link href="Styles/Base.css" rel="stylesheet" />
    <style>
        body {
            padding: 0;
            margin: 0;
        }

        #container {
            padding: 30px;
        }

        textarea {
            width: 100%;
        }
    </style>
    <script src="Scripts/jquery-1.10.2.min.js"></script>
    <script src="NgApp/framework/angular.js"></script>
    <script src="NgApp/framework/angular-route.js"></script>
    <script src="Scripts/jquery.cnoocloading.js"></script>
    <script>
        var app = angular.module("appModule", ["ngRoute"], function () {
            //console.log("main module init");
        });

        var homeController = app.controller("homeController", function ($scope) {
            //console.log("home ctrl");
        });

        app.config(['$routeProvider', function ($routeProvider) {
            $routeProvider.when("/index", {
                templateUrl: "Ngapp/tpls/index.html",
                controller: "homeController"
            }).when("/list", {
                templateUrl: "tpls/list.html",
                controller: "listController"
            }).otherwise({
                redirectTo: "/index"
            });
        }]);

        var eventFns = {
            "#btnFormat click": function () {
                var xml = $("#soapdata").val();
                $.post("test.aspx?ajax=true&m=FormatXml&t=" + new Date().getTime(), { xml: xml }, function (ret) {

                    $("#soapdata").val(ret.xml);
                }, "JSON");
            },
            "#btnPostSoapRequest click": function () {
                var xml = $("#soapdata").val();
                $.post("test.aspx?ajax=true&m=PostSOAPRequest&t=" + new Date().getTime(), { xml: xml }, function (ret) {
                    if (ret.success) {
                        $("#soapresponse").val(ret.xml);
                    } else {
                        alert(ret.error);
                    }

                }, "JSON");
            },
            "#btnResolveWsdl click": function () {
                var xml = $.trim($("#wsdldata").val());
                $("#wsdldata").val(xml);
                $.post("test.aspx?ajax=true&m=ResolveWsdl&t=" + new Date().getTime(), { xml: xml }, function (ret) {
                    $("#wsInfo").html("");
                    var html = [];
                    if (ret) {
                        html.push("<h2>服务名:" + ret.Service + "</h2>");
                        html.push("<p>address location:" + ret.SOAPAddress + "</p>");
                        html.push("<p>名称空间：" + ret.Namespace + "</p>");

                        html.push("服务方法列表：")
                        html.push("<table>");
                        if (ret.Methods) {
                            for (var i = 0; i < ret.Methods.length; i++) {
                                html.push("<tr>");
                                html.push("<td>方法名：" + ret.Methods[i].MethodName + "<br/>");
                                html.push("SOAPAction:" + ret.Methods[i].SOAPAction + "</td>");
                                html.push("</tr>");
                            }
                        }
                        html.push("<//table>");
                    }
                    $("#wsInfo").html(html.join(""));

                }, "JSON");
            }
        };

        $(function () {
            $.CNOOCLoading.init();
            $.ajaxSetup({
                beforeSend: function () {
                    $.CNOOCLoading.show();
                },
                complete: function () {
                    $.CNOOCLoading.hide();
                }
            });
            for (var evt in eventFns) {
                var arr = evt.split(" ");
                $(arr[0]).on(arr[1], eventFns[evt]);
            }
        });
    </script>
</head>
<body ng-controller="homeController">

    <div ng-view></div>

    <form id="form1" runat="server">
        <div id="container">
            WSDL解析：<input type="button" id="btnResolveWsdl" value="解析"><br />
            <textarea name="wsdldata" id="wsdldata" rows="10" style="height:200px;"></textarea>
            <div id="wsInfo"></div>
            <br />

            <br />
            <hr />
            <br />
            SOAP包：<br />
            <fieldset>
                <legend>测试包</legend>
                <div>
                    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&lt;soap:Body&gt;&lt;ZesapfunMm001 xmlns=&quot;urn:sap-com:document:sap:soap:functions:mc-style&quot;&gt;&lt;WhereCondition xmlns=&quot;&quot;&gt;&lt;item&gt;BSART = &#39;FO&#39;&lt;/item&gt;&lt;item&gt;and EBELN like &#39;%45%&#39;&lt;/item&gt;&lt;item&gt;and BUKRS = &#39;2147&#39;&lt;/item&gt;&lt;/WhereCondition&gt;&lt;/ZesapfunMm001&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;
                </div>
            </fieldset>
            <input type="button" id="btnFormat" value="格式化">
            <input type="button" id="btnPostSoapRequest" value="发送请求">
            <textarea name="soapdata" id="soapdata" rows="20"></textarea>
            <br />
            返回内容<br />
            <textarea name="soapresponse" id="soapresponse" rows="20"></textarea>
        </div>
    </form>
</body>
</html>
